﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using EHTSaleManager.Code.BLL;
using EHTSaleManager.Code.Entity;
using EHTSaleManager.Code.Utility;

namespace EHTSaleManager.UIAdmin
{
    public partial class AdminDocuments : System.Web.UI.Page
    {
        private Int32 pageIndex = 1;
        private Int32 pageSize = 5;
        private Int32 totalRecord;

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                pageIndex = Int32.Parse(Request.QueryString["PageIndex"].ToString());
            }
            catch (Exception)
            {
                pageIndex = 1;
            }

            pageSize = this.PaggingControl1.PageSize;

            if (!Page.IsPostBack)
            {
                DataSet dsDocument = DocumentProvider.GetDocumentsWithPaging(pageIndex, pageSize, out totalRecord);
                this.rpDocuments.DataSource = dsDocument;
                this.rpDocuments.DataBind();

                this.PaggingControl1.PageURL = "AdminDocuments.aspx";
                this.PaggingControl1.TotalRecord = totalRecord;
                this.PaggingControl1.PagingSize = pageSize;
            }
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/UIAdmin/AdminDocument.aspx");
        }
    }
}